package com.teatrace.model.produce;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.teatrace.model.base.Device;
import com.teatrace.model.base.Employee;

/**
 * teatrees_check
 */
@Entity
@Table(name="teatrees_check")
public class TeaTreesCheck {

	@Id
	@Column(name="teatrees_check_id")
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int id;//teatrees_check_id

	@ManyToOne
	@JoinColumn(name="teatrees_id",updatable=false)
	private TeaTrees teaTrees;

	@Column(name="check_time",columnDefinition="date")
	private String checkTime;//check_time
	
	private String description;
	
	@OneToOne(cascade={CascadeType.ALL})
	@JoinColumn(name="teatrees_check_detail_id",updatable=true)
	private TeaTreesCheckDetail detail;
	

	@ManyToMany(fetch=FetchType.EAGER,cascade={CascadeType.MERGE,CascadeType.REFRESH,CascadeType.PERSIST})
	@JoinTable(
		name="r_employee_teatreescheck",
		joinColumns=@JoinColumn(name="teatrees_check_id"),
		inverseJoinColumns=@JoinColumn(name="employee_id")
	)
	private Set<Employee> emps;
	
	
	@ManyToMany(fetch=FetchType.EAGER,cascade={CascadeType.MERGE,CascadeType.REFRESH,CascadeType.PERSIST})
	@JoinTable(
		name="r_device_teatreescheck",
		joinColumns=@JoinColumn(name="teatrees_check_id"),
		inverseJoinColumns=@JoinColumn(name="device_id")
	)
	private Set<Device> devices;

	public Set<Employee> getEmps() {
		return emps;
	}

	public void setEmps(Set<Employee> emps) {
		this.emps = emps;
	}

	public Set<Device> getDevices() {
		return devices;
	}

	public void setDevices(Set<Device> devices) {
		this.devices = devices;
	}

	


	public TeaTrees getTeaTrees() {
		return teaTrees;
	}

	public String getCheckTime() {
		return checkTime;
	}

	public String getDescription() {
		return description;
	}

	public void setTeaTrees(TeaTrees teaTrees) {
		this.teaTrees = teaTrees;
	}

	public void setCheckTime(String checkTime) {
		this.checkTime = checkTime;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	public void setDetail(TeaTreesCheckDetail detail) {
		this.detail = detail;
	}

	public TeaTreesCheckDetail getDetail() {
		return detail;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}
	
}
